#ifndef XROS_UTIL_CONFIGPARSER_H_
#define XROS_UTIL_CONFIGPARSER_H_
#include <string>
#include <vector>
#ifdef WIN32
#ifdef util_EXPORTS
#define UTIL_API __declspec(dllexport)
#else
#define UTIL_API __declspec(dllimport)
#endif
#else
#define UTIL_API
#endif
namespace Util {
class ConfigParserImpl;
class UTIL_API ConfigParser
{
public:
    ConfigParser(const char* path);
    ~ConfigParser();
    int create_file(std::string root_name);
    int clear_file();
    int get(std::string exp, int& val, bool is_attr = false);
    int get(std::string exp, std::vector<int>& val, bool is_attr = false);
    int set(std::string exp, int val, bool is_attr = false);
    int add(std::string exp, int val, bool is_attr = false);
    int get(std::string exp, std::string& val, bool is_attr = false);
    int set(std::string exp, std::string val, bool is_attr = false);
    int add(std::string exp, std::string val, bool is_attr = false);
    int get(std::string exp, std::vector<std::string>& val, bool is_attr = false);
    int set(std::string exp, std::vector<std::string> val);
    int get(std::string exp, double& val, bool is_attr = false);
    int set(std::string exp, double val, bool is_attr = false);
    int get(std::string exp, std::vector<double>& val);
    int add(std::string exp, double val, bool is_attr = false);
    int set(std::string exp, std::vector<double> val);
    int get(std::string exp, bool& val, bool is_attr = false);
    int set(std::string exp, bool val, bool is_attr = false);
    int get(std::string exp, std::vector<bool>& val, bool is_attr = false);
    int set(std::string exp, std::vector<bool> val);
    bool is_valid();
    inline const char* path() const { return _path.c_str(); }
    static inline std::string str_append_index(std::string exp, uint32_t index) { return exp + "[" + std::to_string(index) + "]"; }

private:
    ConfigParserImpl* _impl;
    std::string _path;
};
}  // namespace Util
#endif /*XROS_UTIL_CONFIGPARSER_H_*/